package com.taotao.portal.service.ipml;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.taotao.common.pojo.TaotaoResult;
import com.taotao.common.utils.HttpClientUtil;
import com.taotao.common.utils.JsonUtils;
import com.taotao.pojo.TbItem;
import com.taotao.portal.service.IItemService;

@Service
public class ItemServiceIpml implements IItemService {
	@Value("${REST_BASE_URL}")
	private String REST_BASE_URL;

	@Value("${ITME_INFO_URL}")
	private String ITME_INFO_URL;

	@Override
	public TbItem getItemInfoByItemId(Long itemId) {
		// TODO Auto-generated method stub
		String doGet = HttpClientUtil.doGet(REST_BASE_URL + ITME_INFO_URL
				+ itemId);
		if (StringUtils.isNotBlank(doGet)) {
			TaotaoResult taotaoResult = TaotaoResult.formatToPojo(doGet,
					TbItem.class);
			if (200 == taotaoResult.getStatus()) {
				TbItem item = (TbItem) taotaoResult.getData();
				return item;
			}
		}
		return null;
	}
}
